from tortoise import fields
from .base import BaseModel, TimestampMixin

class AppointmentList(BaseModel, TimestampMixin):
    type = fields.IntField(default=1, description="预约大类")
    d_type = fields.IntField(default=1, description="预约子类")
    time = fields.DatetimeField(null=True,max_length=255, description="预约时间")
    city_id = fields.IntField(default=1, description="城市id")
    space_id = fields.IntField(default=1, description="门店id")
    designer_ids = fields.JSONField(null=True, description="技师ids")
    designer_names = fields.JSONField(null=True, description="技师ids")
    project_id = fields.IntField(default=0, null=True, description="项目id")
    project_name = fields.CharField(max_length=255, null=True, description="项目名称")
    ex_project_ids = fields.JSONField(null=True, description="搭配项目id")
    ex_project_names = fields.JSONField(null=True, description="搭配项目名称")
    user_id = fields.IntField(default=0, description="用户id")
    user_name = fields.CharField(max_length=255, description="用户名称")
    user_card_no = fields.IntField(default=0, description="用户卡号")
    user_type = fields.IntField(default=0, description="用户等级")
    user_phone = fields.CharField(max_length=255,null=True, description="用户联系方式")
    come_nums = fields.IntField(default=1, description="预约人数")
    cancel_time = fields.DatetimeField(null=True,max_length=255, description="取消预约时间")
    status = fields.IntField(default=0, description="2:未通过,3：已取消，0：待确认，1：通过")
    extend = fields.JSONField(null=True, description="附加信息")
    order_id = fields.IntField(default=0, description="订单id")
    longs = fields.IntField(default=0, description="操作时长(分钟)")

    class Meta:
        table = "appointment_list"

class AppointmentSpace(BaseModel, TimestampMixin):
    sort = fields.IntField(default=0, description="排序")
    city_id = fields.IntField(default=1, description="城市id")
    type = fields.IntField(default=1, description="门店类型 1 实体 2 虚拟")
    name = fields.CharField(max_length=255, description="门店名称")
    english_name = fields.CharField(max_length=255, description="门店英文名称")
    intro = fields.CharField(max_length=255,description="简介")
    phone = fields.CharField(max_length=255, description="联系电话")
    address = fields.CharField(max_length=255,description="详细地址")
    date = fields.JSONField( null=True, description="可预约日期")
    interval = fields.IntField(default=30, description="时间段间隔")
    start = fields.CharField(max_length=255, description="门店开始预约时间")
    end = fields.CharField(max_length=255, description="门店结束预约时间")
    slot = fields.JSONField( null=True, description="可预约日期的时间段")
    parking_on = fields.BooleanField(default=True, description="是否开启预约停车信息填写")
    parking_cost = fields.IntField(default=0, description="停车费 元/小时")
    project_appointment = fields.BooleanField(default=True, description="是否可以项目预约")
    status = fields.BooleanField(default=True, description="状态 0：未开通，1：开通")
    picture = fields.CharField(max_length=255, description="封面")
    images = fields.JSONField( null=True, description="详情组图")
    content_pic = fields.JSONField(null=True, description="图文介绍")
    project_roles = fields.JSONField(null=True, description="项目规则")
    lat = fields.CharField(max_length=255, description="经度")
    lon = fields.CharField(max_length=255, description="纬度")

    class Meta:
        table = "appointment_space"

class AppointmentProject(BaseModel, TimestampMixin):
    sort = fields.IntField(default=0, description="排序")
    pid = fields.IntField(default=0, description="关联仪器id")
    name = fields.CharField(max_length=255, description="项目名称")
    type =  fields.IntField(default=0, description="类别")
    online = fields.BooleanField(default=True, description="是否需要线上预约")
    status = fields.BooleanField(default=True, description="状态 0：未开通，1：开通")
    interval = fields.IntField(default=0, description="时长")
    goods_id = fields.IntField(default=0, max_length=10, description="关联商品id")
    sku_id = fields.IntField(default=0, max_length=10, description="关联规格id")
    cover = fields.CharField(max_length=255, null=True, description="封面")
    project_images = fields.JSONField(null=True, description="详情组图")
    class Meta:
        table = "appointment_project"

class AppointmentInstrument(BaseModel, TimestampMixin):
    space_id = fields.IntField(default=0, description="门店id")
    instrument_id = fields.IntField(default=0, description="仪器id")
    interval = fields.IntField(default=30, description="间隔")
    num = fields.IntField(default=1, description="数量")
    date = fields.JSONField( null=True, description="可预约日期")

    class Meta:
        table = "appointment_instrument"

class AppointmentDesigner(BaseModel, TimestampMixin):
    sort = fields.IntField(default=0, description="排序")
    name = fields.CharField(max_length=255, description="对象名称")
    space_id = fields.JSONField(null=True, description="多选,门店id")
    type = fields.IntField(default=0, description="对象类型1助理2美学设计3医生")
    doctor_type = fields.JSONField(null=True, description="医生类型[微美，皮肤，口腔，私密，中医]")
    title = fields.CharField(max_length=255, description="称号")
    intro = fields.CharField(max_length=255,null=True,  description="简介")
    picture = fields.CharField(max_length=255,null=True,  description="头像地址")
    images = fields.JSONField(null=True, description="组图")
    status = fields.BooleanField(default=True, description="状态 0：未开通，1：开通")
    open_roles = fields.JSONField(null=True, description="开放规则")
    close_roles = fields.JSONField(null=True, description="关闭规则")
    project_roles = fields.JSONField(null=True, description="项目规则")

    class Meta:
        table = "appointment_designer"

class AppointmentSalon(BaseModel, TimestampMixin):
    sort = fields.IntField(default=0, description="排序")
    role_id = fields.JSONField(null=True, description="可以预约的角色类型,多选")
    kind = fields.IntField(default=1, description="1：内部沙龙，2：外部沙龙")
    type_id = fields.IntField(default=1, description="1：会员沙龙，2：微美沙龙")
    is_brand = fields.BooleanField(default=True, description="是否是品牌联名")
    name = fields.CharField(max_length=255, description="沙龙名称")
    english_name = fields.CharField(max_length=255, description="沙龙英文名称")
    desc = fields.CharField(max_length=255, description="描述")
    picture = fields.CharField(max_length=255, description="封面")
    content_pic = fields.JSONField(null=True, description="组图")
    start_time = fields.DatetimeField(null=True, description="门店开始预约时间")
    end_time = fields.DatetimeField(null=True, description="门店结束预约时间")
    date = fields.DatetimeField(null=True, description="举办日期")
    city_id = fields.IntField(default=0, description="城市id")
    space_id = fields.IntField(default=0, description="门店id")
    location = fields.CharField(max_length=255, description="举办地址")
    number = fields.IntField(default=0, description="人数")
    is_accompany = fields.BooleanField(default=True, description="是否可带人")
    show_add = fields.IntField(default=0, description="显示增加人数")
    number_have = fields.IntField(default=0, description="实际报名人数")
    times = fields.BooleanField(default=True, description="是否控制每月次数")
    status = fields.BooleanField(default=True, description="状态 0：未开通，1：开通")
    need_parking = fields.BooleanField(default=True, description="是否需要泊车")
    parking_price = fields.IntField(default=0, description="泊车单价")

    class Meta:
        table = "appointment_salon"

class AppointmentLock(BaseModel, TimestampMixin):
    user_id = fields.IntField(default=0, description="用户ID")
    designer_ids = fields.JSONField(default=None, description="技师IDs")
    time = fields.DatetimeField(null=True,max_length=255, description="预约时间")
    longs = fields.IntField(default=0, description="操作时长")

    class Meta:
        table = "appointment_lock"


class AppointmentCategory(BaseModel, TimestampMixin):
    name = fields.CharField(max_length=255, null=True, description="项目分类名称")
    desc = fields.CharField(max_length=500,null=True, description="备注")
    is_deleted = fields.BooleanField(default=False, description="软删除标记")
    order = fields.IntField(default=0, description="排序")
    parent_id = fields.IntField(default=0, max_length=10, description="父分类ID")
    cover = fields.CharField(max_length=255, null=True, description="封面")
    goods_id = fields.IntField(default=0, max_length=10, description="关联商品id")
    sku_id = fields.IntField(default=0, max_length=10, description="关联规格id")

    class Meta:
        table = "appointment_category"